<?php  
/**
 * @package Spider Contacts
 * @author Web-Dorado
 * @copyright (C) 2012 Web-Dorado. All rights reserved.
 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 **/
defined('_JEXEC') or die('Restricted access'); 
	$rows=$this->rows;
	$option=$this->option;
	$params=$this->params;
	$category_name=$this->category_name;	
	$session =JFactory::getSession();
	
?>
<div>

<?php 


if ($params->get('viewcontact_radius')):
?>
<style type="text/css">
#contactMainDiv, .spidercontactbutton, .spidercontactinput
{
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}

#contactMainDiv #contTitle
{
-webkit-border-top-right-radius: 8px;
-webkit-border-top-left-radius: 8px;
-moz-border-radius-topright: 8px;
-moz-border-radius-topleft: 8px;
border-top-right-radius: 8px;
border-top-left-radius: 8px;
}
</style>
<?php
endif;

if  (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'] ,'showcube'))

{
	$back = str_replace('showcontact','showcube',$_SERVER['QUERY_STRING']);
}

else if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'] ,'showtable') )

{	
	$back = str_replace('showcontact','showtable',$_SERVER['QUERY_STRING']);
	
	}
	
	else 

{
	$back = str_replace('showcontact','spidercontacts',$_SERVER['QUERY_STRING']);
}
if ($params->get('viewcontact_radius') == 0)
  {		$border_radius = '';	}
  
  else {
	  		$border_radius = " border-radius:8px; -moz-border-radius: 8px; -webkit-border-radius: 8px;";
	  }  

foreach($rows as $row){
	
if(JRequest::getVar('back',''))
{
echo '<span id="back_to_spidercontact_button"><a href="'.JRoute::_('index.php?'.$back ).'" >'.JText::_('SH_BACK_TO_CONTACT').'</a></span>';
}

echo '<div id="contactMainDiv" style=" '.$border_radius.' border-width:'.$params->get( 'viewcontact_border_width' ).'px;border-color:'.$params->get( 'viewcontact_border_color' ).';border-style:'.$params->get( 'viewcontact_border_style' ).';'.(($params->get( 'text_size_big' )!='')?('font-size:'.$params->get( 'text_size_big' ).'px;'):'').(($params->get( 'viewcontact_text_color' )!='')?('color:'.$params->get( 'viewcontact_text_color' ).';'):'').(($params->get( 'viewcontact_background_color' )!='')?('background-color:'.$params->get( 'viewcontact_background_color' ).';'):'').'">';


$imgurl=explode(";",$row->image_url);

echo '<div id="contTitle" style="'.(($params->get( 'viewcontact_title_color' )!='')?('color:'.$params->get( 'viewcontact_title_color' ).';'):'').(($params->get( 'viewcontact_title_background_color' )!='')?('background-color:'.$params->get( 'viewcontact_title_background_color' ).';'):'').'padding:0px;"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td  style="padding:10px;font-size:'.$params->get( 'title_size_big' ).'px;">' . $row->first_name.' '.$row->last_name.'</td>';





echo '</tr></table></div>

<br />
<table id="contMiddle" border="0" cellspacing="0" cellpadding="0"><tr>
<tr><td valign="top" width="280">
<table cellpadding="0" cellspacing="5" border="0" style="margin:0px;">';

if(!($row->image_url!="" and $row->image_url!=";")){
$imgurl[0]="components/com_spidercontacts/images/noimage.jpg";echo '<tr><td colspan="2" id="cont_main_picture_container" valign="top"><div style="width:'.($params->get( 'large_picture_width' )).'px;border: #CCCCCC solid 2px;padding:5px;background-color:white;"><div id="cont_main_picture" style="width:'.($params->get( 'large_picture_width' )).'px;height:'.($params->get( 'large_picture_height' )).'px; background:url(index.php?option=com_spidercontacts&view=picture&format=raw&tmpl=component&url='.$imgurl[0].'&height='.$params->get( 'large_picture_height' ).'&width='.$params->get( 'large_picture_width' ).'&reverse=1) center no-repeat;">&nbsp;</div></div></td></tr>';}else
echo '
<tr><td colspan="2" id="cont_main_picture_container" valign="top">
<div style="width:'.($params->get( 'large_picture_width' )).'px;border: #CCCCCC solid 2px;padding:5px;background-color:white;">
<a href="'.$imgurl[0].'" target="_blank" id="cont_main_picture_a" style="text-decoration:none;">
<div id="cont_main_picture" style="width:'.($params->get( 'large_picture_width' )).'px;height:'.($params->get( 'large_picture_height' )).'px; background:url(index.php?option=com_spidercontacts&view=picture&format=raw&tmpl=component&url='.$imgurl[0].'&height='.$params->get( 'large_picture_height' ).'&width='.$params->get( 'large_picture_width' ).'&reverse=1) center no-repeat;">&nbsp;</div></a></div>

</td></tr>';
echo'
<tr><td style="text-align:justify;">';

$small_images_str='';
$small_images_count=0;

foreach($imgurl as $img)
{
if($img!=='')
{
$small_images_str.='<a href="'.$img.'" target="_blank"><img src="index.php?option=com_spidercontacts&view=picture&format=raw&tmpl=component&url='.$img.'&height='.$params->get("small_pic_size").'" vspace="5" hspace="5" onMouseOver="cont_change_picture(\''.$img.'\',this,'.$params->get( 'large_picture_width' ).','.$params->get( 'large_picture_height' ).');" /></a>
';
$small_images_count++;
}
}
if($small_images_count>1)
echo $small_images_str;
else
echo '&nbsp;';

echo '</td></tr><td valign="top">';


echo '</td></tr></table>';

echo '<td valign="top" align="right">';


	echo '<table  border="1" style=" '. $border_radius. ' border-style:solid; border-color:'.$params->get( 'viewcontact_border_color' ).'; " > <tr> <td  style="border:none  "> <table  ' .(($params->get( 'viewcontact_background_color' )!='')?('bordercolor="'.$params->get( 'viewcontact_background_color' ).'"'):' ').'    id="paramstable"  style=" '.$border_radius. ' border-style:solid; " border="1" cellspacing="0" cellpadding="5" width="100%">';

if($category_name!="")
echo '<tr valign="top" style=" '.(($params->get( 'viewcontact_params_background_color2' )!='')?('background-color:'.$params->get( 'viewcontact_params_background_color2' ).';'):'').' vertical-align:middle;"><td><b>'.JText::_('SH_CATEGORY').'</b></td><td style="'.(($params->get( 'viewcontact_params_color' )!='')?('color:'.$params->get( 'viewcontact_params_color' ).';'):'').'"><span id="cat_' . $row->id . '">' .$category_name.'</span></td></tr>';
else
echo '<span id="cat_' . $row->id . '"></span>';

if($row->email !="")
echo '<tr valign="top" style=" '.(($params->get( 'viewcontact_params_background_color1' )!='')?('background-color:'.$params->get( 'viewcontact_params_background_color1' ).';'):'').' vertical-align:middle;"><td ><b>'.JText::_('SH_EMAIL').'</b></td><td style="'.(($params->get( 'params_color' )!='')?('color:'.$params->get( 'viewcontact_params_color' ).';'):'').'"><span id="email_' . $row->id . '"><a href="mailto:' .$row->email. '">' .$row->email. '</a></span></td></tr>';
else
echo '<span id="email_' . $row->id . '"></span>';

		
			







//--------------------------------------------------------------------------

$par_data=explode("par_",$row->param);

for($j=0;$j<count($par_data);$j++)
	if($par_data[$j]!='')
	{

		$par1_data=explode("@@:@@",$par_data[$j]);

		$par_values=explode("	",$par1_data[1]);

				$countOfPar=0;
					for($k=0;$k<count($par_values);$k++)
						if($par_values[$k]!="")
						$countOfPar++;
		$bgcolor=(($j%2)?(($params->get( 'viewcontact_params_background_color2' )!='')?('background-color:'.$params->get( 'viewcontact_params_background_color2' ).';'):''):(($params->get( 'viewcontact_params_background_color1' )!='')?('background-color:'.$params->get( 'viewcontact_params_background_color1' ).';'):''));	


		if($countOfPar!=0)
		{
		
                echo '<tr  valign="top" style="' . $bgcolor . 'text-align:left"><td><b>' . $par1_data[0] . ':</b></td>';
                

                    echo '<td style="' . (($params->get('text_size_small') != '') ? ('font-size:' . $params->get('text_size_small') . 'px;') : '') . $bgcolor . (($params->get('viewcontact_params_color') != '') ? ('color:' . $params->get('viewcontact_params_color') . ';') : '') . 'width:' . $params->get('parameters_select_box_width') . 'px;"><ul class="spidercontactparamslist">';
                    
                    for ($k = 0; $k < count($par_values); $k++)
                        if ($par_values[$k] != "")
						{
							if (preg_match('/(http:\/\/[^\s]+)/', $par_values[$k], $text))
							{
							$hypertext = "<a target=\"_blank\" href=\"". $text[0] . "\">" . $text[0] . "</a>";
							$newString = preg_replace('/(http:\/\/[^\s]+)/', $hypertext, $par_values[$k]);
							echo '<li>' . $newString . '</li>';
							}
							else if (preg_match('/(https:\/\/[^\s]+)/', $par_values[$k], $text))
							{ 
								$hypertext = "<a target=\"_blank\" href=\"". $text[0] . "\">" . $text[0] . "</a>";
							$newString = preg_replace('/(https:\/\/[^\s]+)/', $hypertext, $par_values[$k]);
							echo '<li>' . $newString . '</li>';
								}
							
						 else if ($par_values[$k])
                            echo '<li>' . $par_values[$k] . '</li>';
						}
                    
                    echo '</ul></td></tr>';

		}
	}	
//--------------------------------------------------------------------------




$desc =   str_replace('<hr id="system-readmore" />', '<hr style="display:none;" id="system-readmore">',  $row->description);
echo '</table>
</td></tr></table> </td>  </tr> </table><br />

<div style="'. (($params->get('description_text_color') != '') ? ('color:' . $params->get('description_text_color') . ';') : '') .'" id="contAllDescription">' . $desc . '</div><br />
<br />';




	echo '</div>';
	}
	
	
if ($params->get('enable_message', ''))
{
echo '<div><a name="mes" style="color:inherit;text-decoration:inherit;">'.JText::_('SH_ADD_MESSAGE').'</a></div>';

$url=$_SERVER['QUERY_STRING'];


//echo '<div style="border:;margin:3px; padding:10px; ">';


echo '<div  id="message_div" style=" '.$border_radius.' padding:10px; border-width:'.$params->get( 'viewcontact_border_width' ).'px;border-color:'.$params->get( 'viewcontact_border_color' ).';border-style:'.$params->get( 'viewcontact_border_style' ).';'.(($params->get( 'messages_background_color' )!='')?('background-color:'.$params->get( 'messages_background_color' ).';'):'').'">';


echo '<form  action="'.$_SERVER["REQUEST_URI"].'#mes"  name="message" method="post" >';


			if ($params->get( 'show_name' ))
			{
			echo '	<div style="font-weight:bold;">'.JText::_('SH_YOUR_NAME').'</div>

				<input type="text" name="full_name" id="full_name" style="width:98%; margin:0px;" />
<br />
<br />';
			}
			
			else { echo' <input type="hidden" name="full_name" id="full_name" value ="No Name" /> ';}
			
			
			if ($params->get( 'show_phone' ))
			{

echo '<div style="font-weight:bold;">'.JText::_('SH_PHONE').'</div>

				<input type="text" name="phone" id="phone" style="width:98%; margin:0px;" />
<br />
<br />';
			}
			
			else { echo' <input type="hidden" name="phone" id="phone" value="No Phone"  /> ';}
			if ($params->get( 'show_email' ))
			{

echo '<div style="font-weight:bold;">'.JText::_('SH_MAIL').'</div>

				<input type="email" name="email" id="email" style="width:98%; margin:0px;" />
<br />
<br />';
			}
			
			else {
				echo '<input type="hidden" name="email" id="email" value="No Email"/>';}
				
				
				if ($params->get( 'show_cont_pref' ) && $params->get( 'show_email' ) && $params->get( 'show_phone' ))
			{
				

echo '<div style="font-weight:bold;">'.JText::_('SH_CONT_PREF').'</div>';

				
			echo '<input type="radio" name="cont_pref" id="cont_pref1" value="1" style="width:98%; margin:0px;" /><label for="cont_pref1">Phone</label>
				<input type="radio" name="cont_pref" id="cont_pref0" value="0" checked="checked" style="width:98%; margin:0px;" /><label for="cont_pref0">Mail</label>
				<input type="radio" name="cont_pref" id="cont_pref2" value="2" style="width:98%; margin:0px;" /><label for="cont_pref2">Either</label>

<br />
<br />';


			}
			
			else {
				echo '<input type="hidden" name="cont_pref" id="cont_pref" value="Disabled"/>';}
				
			echo '<div style="font-weight:bold;">'.JText::_('SH_TITLE').'</div>

				<input type="text" name="mes_title" id="mes_title" style="width:98%; margin:0px;" />
<br />
<br />



				<div style="font-weight:bold;">'.JText::_('SH_MESSAGE').'</div>
				<textarea rows="4" name="message_text" id="message_text" style="width:98%; margin:0px;"></textarea>
			<input type="hidden" name="want_email" value="'.$row->want_email.'" />	
	<input type="hidden" name="contact_id" value="'.$row->id.'" />
	<input type="hidden" name="view" value="showcontact" />
	<input type="hidden" name="is_message" value=true />
	<input type="hidden" name="option" value="'.$option.'" />';

	?><br />
<br />

    <table id="cap_table" cellpadding="0" cellspacing="10" border="0" valign="middle" width="100%"> <tr><td>
    <?php echo JText::_('SH_ENTER_THE_CODE') ?>
    </td><td>
   <span id="wd_captcha"><img src="index.php?option=com_spidercontacts&view=wdcaptcha&format=raw&tmpl=component" id="wd_captcha_img" height="24" width="80" /></span><a href="javascript:refreshCaptcha();" style="text-decoration:none">&nbsp;<img src="components/<?php echo $option ?>/images/refresh.png" border="0" style="border:none" /></a>&nbsp;</td><td><input type="text" name="code" id="message_capcode" size="6" /><span id="caphid"></span>
   </td>
   <td width="40%" align="right">   
   <input type="button" class="spidercontactbutton" style="<?php echo 'background-color:'.$params->get( 'button_background_color' ).'; color:'.$params->get( 'button_color' ) ?>; width:inherit;margin-right:10px;"  value="<?php echo JTEXT::_('SH_SEND') ?>" onclick='submit_message("<?php echo JText::_('SH_NAME_REQUIRED'); ?>","<?php echo JText::_('SH_MESSAGE_REQUIRED'); ?>", "<?php echo JText::_('SH_TITLE_REQUIRED'); ?>", "<?php echo JText::_('SH_WRONG_CAPTCHA'); ?>",  "<?php echo JText::_('SH_PHONE_REQUIRED'); ?>",  "<?php echo JText::_('SH_EMAIL_REQUIRED'); ?>" );' />
   </td>
	</tr></table>

	</form>
	
 <?php
 
    $code=JRequest::getVar('code','');
	
	
}
	
		?>
	</div><br /><br /></div>
    
      
<script type="text/javascript">
var SpiderCatOFOnLoad = window.onload;
window.onload = SpiderCatAddToOnload;
</script>
  